

-- Namespace
	local _,mod = ...


-- Object reference
	local units = mod.units
	local resolve = mod.resolve


-- GCD
	local care = mod:unitevent_care('gcd')
	if care and care['player'] then
		local function GCD()
			local u = units['player']
			if not u then return end
			
			local s,d = GetSpellCooldown(61304)
			if d > 0 then
				u:Update('gcd',s,d)
			else
				u:Update('gcd',nil)
			end
		end
		
		mod:event_register('ACTIONBAR_UPDATE_COOLDOWN',GCD)
	end


-- Casting
	local care = mod:unitevent_care('casting')
	if care then
		local function CASTING(unit)
			if not care[unit] then return end
			local u = units[unit]
			
			local channel
			local name,_,_,icon,startT,endT,_,_,interrupt = UnitCastingInfo(unit)
			if not name then
				name,_,_,icon,startT,endT,_,_,interrupt = UnitChannelInfo(unit)
				if name then
					channel = true
				else
					u:Update('casting',nil)
					return
				end
			end
			
			startT = startT * .001
			endT = endT * .001
			
			u:Update('casting',name,icon,startT,endT,interrupt,channel)
		end
		
		mod:event_register('UNIT_SPELLCAST_START',CASTING)
		mod:event_register('UNIT_SPELLCAST_CHANNEL_START',CASTING)
		mod:event_register('UNIT_SPELLCAST_STOP',CASTING)
		mod:event_register('UNIT_SPELLCAST_CHANNEL_STOP',CASTING)
		mod:event_register('UNIT_SPELLCAST_DELAYED',CASTING)
		mod:event_register('UNIT_SPELLCAST_CHANNEL_UPDATE',CASTING)
		
		resolve[#resolve+1] = CASTING
	end
